package com.azzcs.mvc.mav;

import com.azzcs.spring.anno.Component;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

/**
 * @Author: wzg
 * @Date: 2020/12/29 下午2:50
 */
@Component
public class SimpleView implements View{
    @Override
    public void render(Model model, HttpServletRequest request, HttpServletResponse resp) {
        resp.setStatus(HttpServletResponse.SC_OK);
        resp.setHeader("Content-type", "text/html;charset=UTF-8");
        resp.setCharacterEncoding("UTF-8");
        try {
            final PrintWriter printWriter = resp.getWriter();
            if(model != null){
                printWriter.println("下面是 model 中的值：");
                model.forEach((k, v)->{
                    printWriter.println("["+k+","+v+"]");
                });
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
